<template>
	<!-- 我的优惠卷界面 -->
	<view class="app">
		<view class="discount_top clear">
			<view class="tab" :class="{active:activeTab === 'unused'}"  @click="switchTab('unused')">未使用</view>
			<view class="tab" :class="{active:activeTab === 'used' }"  @click="switchTab('used')">已使用</view>
			<view class="tab" :class="{active:activeTab === 'expired' }"  @click="switchTab('expired')">已过期</view>
		</view>
		<!-- 未使用的优惠卷 -->
		<view class="discount_bottom" v-if="weiMsg">
			<view class="center clear">
				<view :style="{backgroundColor:moneyBGcolor}">
					<view>￥{{money}}</view>
					<view>满200可用</view>
				</view>
				<view>
					<view>通用/仅限用于{{name}}加油站使用</view>
					<view :style="{color:TimeColor}">
						<text>{{startTime}}至{{endTime}}</text>
						<text :style="{backgroundColor:titleColor}">{{title}}</text>
					</view>
				</view>
			</view>
			<view class="center clear">
				<view :style="{backgroundColor:moneyBGcolor}">
					<view>￥{{money}}</view>
					<view>满200可用</view>
				</view>
				<view>
					<view>通用/仅限用于{{name}}加油站使用</view>
					<view :style="{color:TimeColor}">
						<text>{{startTime}}至{{endTime}}</text>
						<text :style="{backgroundColor:titleColor}">{{title}}</text>
					</view>
				</view>
			</view>
		</view>
		<!-- 已使用的优惠卷 -->
		<view class="discount_bottom" v-else-if="yiMsg">
			<view class="center clear">
				<view :style="{backgroundColor:moneyBGcolor,color:moneycolor}">
					<view>
						￥{{money}}
					</view>
					<view>
						满200可用
					</view>
				</view>
				<view>
					<view>
						通用/仅限用于{{name}}加油站使用
					</view>
					<view>
						<text :style="{color:TimeColor}">
							{{startTime}}至{{endTime}}
						</text>
						<text :style="{backgroundColor:titleColor}">{{title}}</text>
					</view>
				</view>
			</view>
			<view class="center clear">
				<view :style="{backgroundColor:moneyBGcolor,color:moneycolor}">
					<view>
						￥{{money}}
					</view>
					<view>
						满200可用
					</view>
				</view>
				<view>
					<view>
						通用/仅限用于{{name}}加油站使用
					</view>
					<view :style="{color:TimeColor}">
						<text>
							{{startTime}}至{{endTime}}
						</text>
						<text :style="{backgroundColor:titleColor}">{{title}}</text>
					</view>
				</view>
			</view>
		</view>
		<!-- 已过期的优惠卷 -->
		<view class="discount_bottom" v-else="guoiMsg">
			<view class="center clear">
				<view :style="{backgroundColor:moneyBGcolor,color:moneycolor}">
					<view>
						￥{{money}}
					</view>
					<view>
						满200可用
					</view>
				</view>
				<view>
					<view>
						通用/仅限用于{{name}}加油站使用
					</view>
					<view>
						<text :style="{color:TimeColor}">
							{{startTime}}至{{endTime}}
						</text>
						<text :style="{backgroundColor:titleColor}">{{title}}</text>
					</view>
				</view>
			</view>
			<view class="center clear">
				<view :style="{backgroundColor:moneyBGcolor,color:moneycolor}">
					<view>
						￥{{money}}
					</view>
					<view>
						满200可用
					</view>
				</view>
				<view>
					<view>
						通用/仅限用于{{name}}加油站使用
					</view>
					<view :style="{color:TimeColor}">
						<text>
							{{startTime}}至{{endTime}}
						</text>
						<text :style="{backgroundColor:titleColor}">{{title}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title:"立即使用",
				activeTab: 'unused',
				name: "中国石化",
				money: 100,
				startTime: "2020.04.11",
				endTime: "2020.05.11",
				useStatus: ["未使用", "已使用", "已过期"],
				weiMsg: true,
				yiMsg: false,
				guoMsg: false,
				// 优惠卷的背景色
				moneyBGcolor:"dodgerblue",
				//时间的背景颜色
				TimeColor:"red",
				titleColor:"dodgerblue",
				//已使用和已过期的字体的颜色
				moneycolor:"black"
			}
		},
		methods: {
			switchTab(tab) {
				if (tab === 'unused') {
					this.weiMsg = true,
						this.yiMsg = false,
						this.guoMsg = false,
						this.title="立即使用",
						this.moneyBGcolor="dodgerblue",
						this.TimeColor="red",
						this.titleColor="dodgerblue"
				}
				if (tab === 'used') {
					this.weiMsg = false,
						this.yiMsg = true,
						this.guoMsg = false,
						this.title="已使用",
						this.moneyBGcolor="white",
						this.TimeColor="grey",
						this.titleColor="gray"
				} if(tab === 'expired') {
					this.weiMsg = false,
						this.yiMsg = false,
						this.guoMsg = true,
						this.title="已过期",
						this.moneyBGcolor="white",
						this.TimeColor="grey",
						this.titleColor="gray"
				};
				this.activeTab = tab;
			}

		}
	}
</script>

<style>
	.app {
		width: 99%;
		/* 		border: 2px solid red; */
	}

	.discount_top {
		height: 100rpx;
		/* 		border: 2px solid blue; */
		font-size: 30rpx;

	}

	.discount_top>view {
		float: left;
		margin: 20rpx 70rpx;
	}

	.center {
		width: 100%;
		height: 220rpx;
	}

	.center>view:first-child {
		margin: 20rpx 0 0 20rpx;
		width: 30%;
		height: 150rpx;
		float: left;
		border-radius: 20rpx;
		/* background-color: dodgerblue; */
		text-align: center;
		color: white;
	}

	.center>view:first-child>view:first-child {
		margin: 35rpx 60rpx 0 30rpx;
		font-size: 40rpx;
	}

	.center>view:nth-child(2) {
		margin: 10rpx 0;
		width: 63%;
		height: 180rpx;
		float: right;
		border-left: rgba(0, 0, 0, 0.2) 2px solid;
	}

	.center>view:first-child>view:nth-child(2) {
		margin-top: 10rpx;
		
		/* color: white; */
	}

	.center>view:nth-child(2)>view:first-child {
		margin: 15rpx 0 10rpx 20rpx;
		font-size: 25rpx;
	}

	.center>view:nth-child(2)>view:nth-child(2) {
		/* color: red; */
		font-size: 20rpx;
		margin: 60rpx 0 10rpx 30rpx;
	}

	.center>view:nth-child(2)>view:nth-child(2)>text:last-child {
		display: inline-block;
		width: 120rpx;
		height: 50rpx;
		margin: 0 0 10rpx 30rpx;
		border-radius: 10rpx;
		text-align: center;
		color: white;
		padding-top: 15rpx;
		/* background-color: dodgerblue; */
	}

	.active {
		color: dodgerblue;
	}
</style>